package com.scs.application.modules.svn.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.modules.svn.entity.SvnVersion;
import com.scs.application.modules.svn.service.SvnVersionService;
import com.scs.application.modules.svn.utils.UtilSvn;
import com.scs.application.modules.sys.model.RestResult;
import com.scs.application.modules.sys.properties.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * svn版本记录表 前端控制器
 * </p>
 */
@RestController
@RequestMapping("/svn/version")
public class SvnVersionController extends CrudController<SvnVersionService, SvnVersion> {

    @Autowired
    private SystemProperties systemProperties;

    /**
     * 将svn版本信息同步到svn_version表，增量
     *
     * @return
     */
    @GetMapping("/initSvnVersion")
    public RestResult initSvnVersion(String clear) {
        if ("1".equals(clear)) this.service.remove(Wrappers.query());
        return RestResult.ok(systemProperties.getFlagProject() ? "" : UtilSvn.initSvnVersion(true));
    }

}
